package com.jintian.smart.kernel.orm.event;

import com.jintian.smart.kernel.orm.enums.DmlAction;
import org.springframework.core.ResolvableType;
import org.springframework.core.ResolvableTypeProvider;

import java.util.List;

public class EntityDmlEvent<T> implements ResolvableTypeProvider {
    private static final long serialVersionUID = 1L;
    private DmlAction action;
    private String execute;
    private Class<T> beanClass;
    private String path;

    private List<T> source;

    private List<T> target;

    public EntityDmlEvent(String path, DmlAction action, String execute, Class<T> beanClass, List source) {
        this.path = path;
        this.action = action;
        this.execute = execute;
        this.beanClass = beanClass;
        this.source = source;
        this.target = source;
    }

    public EntityDmlEvent(String path, DmlAction action, String execute, Class<T> beanClass, List source, List target) {
        this.path = path;
        this.action = action;
        this.execute = execute;
        this.beanClass = beanClass;
        this.source = source;
        this.target = target;
    }

    public EntityDmlEvent(String path, DmlAction action, Class<T> beanClass, List source) {
        this.path = path;
        this.action = action;
        this.beanClass = beanClass;
        this.source = source;
        this.target = source;
    }

    public EntityDmlEvent(String path, DmlAction action, Class<T> beanClass, List source, List target) {
        this.path = path;
        this.action = action;
        this.beanClass = beanClass;
        this.source = source;
        this.target = target;
    }

    public DmlAction getAction() {
        return this.action;
    }

    public String getPath() {
        return this.path;
    }

    public Class<T> getBeanClass() {
        return this.beanClass;
    }

    public void setBeanClass(Class<T> beanClass) {
        this.beanClass = beanClass;
    }

    public List getSource() {
        return this.source;
    }

    public List getTarget() {
        return target;
    }

    public void setTarget(List target) {
        this.target = target;
    }

    @Override
    public ResolvableType getResolvableType() {
        return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forClass(beanClass));
    }
}
